/*   1:    */ package org.jetbrains.jps.model.serialization.java.compiler;
/*   2:    */ 
/*   3:    */

import com.intellij.openapi.util.JDOMExternalizerUtil;
import com.intellij.openapi.util.JDOMUtil;
import com.intellij.openapi.util.text.StringUtil;
import org.jdom.Element;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jps.model.JpsProject;
import org.jetbrains.jps.model.java.JpsJavaExtensionService;
import org.jetbrains.jps.model.java.compiler.JpsCompilerExcludes;
import org.jetbrains.jps.model.java.compiler.JpsJavaCompilerConfiguration;
import org.jetbrains.jps.model.serialization.JpsProjectExtensionSerializer;

import java.util.Iterator;
import java.util.List;

/*   4:    */
/*   5:    */
/*   6:    */
/*   7:    */
/*   8:    */
/*   9:    */
/*  10:    */
/*  11:    */
/*  12:    */
/*  13:    */
/*  14:    */
/*  15:    */ 
/*  16:    */ public class JpsJavaCompilerConfigurationSerializer
/*  17:    */   extends JpsProjectExtensionSerializer
/*  18:    */ {
/*  19:    */   public static final String EXCLUDE_FROM_COMPILE = "excludeFromCompile";
/*  20:    */   public static final String RESOURCE_EXTENSIONS = "resourceExtensions";
/*  21:    */   public static final String ANNOTATION_PROCESSING = "annotationProcessing";
/*  22:    */   public static final String BYTECODE_TARGET_LEVEL = "bytecodeTargetLevel";
/*  23:    */   public static final String WILDCARD_RESOURCE_PATTERNS = "wildcardResourcePatterns";
/*  24:    */   public static final String ADD_NOTNULL_ASSERTIONS = "addNotNullAssertions";
/*  25:    */   public static final String ENTRY = "entry";
/*  26:    */   public static final String NAME = "name";
/*  27:    */   public static final String ENABLED = "enabled";
/*  28:    */   public static final String MODULE = "module";
/*  29:    */   public static final String TARGET_ATTRIBUTE = "target";
/*  30:    */   
/*  31:    */   public JpsJavaCompilerConfigurationSerializer()
/*  32:    */   {
/*  33: 48 */     super("compiler.xml", "CompilerConfiguration");
/*  34:    */   }
/*  35:    */   
/*  36:    */   public void loadExtension(@NotNull JpsProject paramJpsProject, @NotNull Element paramElement)
/*  37:    */   {
/*  38: 53 */     if (paramJpsProject == null) {
/*  39: 53 */       throw new IllegalArgumentException(String.format("Argument %s for @NotNull parameter of %s.%s must not be null", new Object[] { "0", "org/jetbrains/jps/model/serialization/java/compiler/JpsJavaCompilerConfigurationSerializer", "loadExtension" }));
/*  40:    */     }
/*  41: 53 */     if (paramElement == null) {
/*  42: 53 */       throw new IllegalArgumentException(String.format("Argument %s for @NotNull parameter of %s.%s must not be null", new Object[] { "1", "org/jetbrains/jps/model/serialization/java/compiler/JpsJavaCompilerConfigurationSerializer", "loadExtension" }));
/*  43:    */     }
/*  44: 53 */     JpsJavaCompilerConfiguration localJpsJavaCompilerConfiguration = JpsJavaExtensionService.getInstance().getOrCreateCompilerConfiguration(paramJpsProject);
/*  45: 54 */     Element localElement1 = paramElement.getChild("addNotNullAssertions");
/*  46: 55 */     if (localElement1 != null) {
/*  47: 56 */       localJpsJavaCompilerConfiguration.setAddNotNullAssertions(Boolean.parseBoolean(localElement1.getAttributeValue("enabled", "true")));
/*  48:    */     }
/*  49: 59 */     readExcludes(paramElement.getChild("excludeFromCompile"), localJpsJavaCompilerConfiguration.getCompilerExcludes());
/*  50:    */     
/*  51: 61 */     Element localElement2 = paramElement.getChild("wildcardResourcePatterns");
/*  52: 62 */     for (Object localObject1 = JDOMUtil.getChildren(localElement2, "entry").iterator(); ((Iterator)localObject1).hasNext();)
/*  53:    */     {
/*  54: 62 */       localObject2 = (Element)((Iterator)localObject1).next();
/*  55: 63 */       localObject3 = ((Element)localObject2).getAttributeValue("name");
/*  56: 64 */       if (!StringUtil.isEmpty((String)localObject3)) {
/*  57: 65 */         localJpsJavaCompilerConfiguration.addResourcePattern((String)localObject3);
/*  58:    */       }
/*  59:    */     }
/*  60: 69 */     localObject1 = paramElement.getChild("annotationProcessing");
/*  61: 70 */     if (localObject1 != null)
/*  62:    */     {
/*  63: 71 */       localObject2 = JDOMUtil.getChildren((Element)localObject1, "profile");
/*  64: 72 */       for (localObject3 = ((List)localObject2).iterator(); ((Iterator)localObject3).hasNext();)
/*  65:    */       {
/*  66: 72 */         localElement3 = (Element)((Iterator)localObject3).next();
/*  67: 73 */         boolean bool = Boolean.parseBoolean(localElement3.getAttributeValue("default"));
/*  68: 74 */         if (bool) {
/*  69: 75 */           AnnotationProcessorProfileSerializer.readExternal(localJpsJavaCompilerConfiguration.getDefaultAnnotationProcessingProfile(), localElement3);
/*  70:    */         } else {
/*  71: 78 */           AnnotationProcessorProfileSerializer.readExternal(localJpsJavaCompilerConfiguration.addAnnotationProcessingProfile(), localElement3);
/*  72:    */         }
/*  73:    */       }
/*  74:    */     }
/*  75:    */     Element localElement3;
/*  76: 83 */     Object localObject2 = paramElement.getChild("bytecodeTargetLevel");
/*  77: 84 */     if (localObject2 != null)
/*  78:    */     {
/*  79: 85 */       localJpsJavaCompilerConfiguration.setProjectByteCodeTargetLevel(((Element)localObject2).getAttributeValue("target"));
/*  80: 86 */       for (localObject3 = JDOMUtil.getChildren((Element)localObject2, "module").iterator(); ((Iterator)localObject3).hasNext();)
/*  81:    */       {
/*  82: 86 */         localElement3 = (Element)((Iterator)localObject3).next();
/*  83: 87 */         String str1 = localElement3.getAttributeValue("name");
/*  84: 88 */         String str2 = localElement3.getAttributeValue("target");
/*  85: 89 */         if ((str1 != null) && (str2 != null)) {
/*  86: 90 */           localJpsJavaCompilerConfiguration.setModuleByteCodeTargetLevel(str1, str2);
/*  87:    */         }
/*  88:    */       }
/*  89:    */     }
/*  90: 94 */     Object localObject3 = JDOMExternalizerUtil.readField(paramElement, "DEFAULT_COMPILER");
/*  91: 95 */     if (localObject3 != null) {
/*  92: 96 */       localJpsJavaCompilerConfiguration.setJavaCompilerId((String)localObject3);
/*  93:    */     }
/*  94:    */   }
/*  95:    */   
/*  96:    */   public static void readExcludes(Element paramElement, JpsCompilerExcludes paramJpsCompilerExcludes)
/*  97:    */   {
/*  98:    */     Iterator localIterator;
/*  99:    */     Element localElement;
/* 100:101 */     if (paramElement != null)
/* 101:    */     {
/* 102:102 */       for (localIterator = JDOMUtil.getChildren(paramElement, "file").iterator(); localIterator.hasNext();)
/* 103:    */       {
/* 104:102 */         localElement = (Element)localIterator.next();
/* 105:103 */         paramJpsCompilerExcludes.addExcludedFile(localElement.getAttributeValue("url"));
/* 106:    */       }
/* 107:105 */       for (localIterator = JDOMUtil.getChildren(paramElement, "directory").iterator(); localIterator.hasNext();)
/* 108:    */       {
/* 109:105 */         localElement = (Element)localIterator.next();
/* 110:106 */         boolean bool = Boolean.parseBoolean(localElement.getAttributeValue("includeSubdirectories"));
/* 111:107 */         paramJpsCompilerExcludes.addExcludedDirectory(localElement.getAttributeValue("url"), bool);
/* 112:    */       }
/* 113:    */     }
/* 114:    */   }
/* 115:    */   
/* 116:    */   public void saveExtension(@NotNull JpsProject paramJpsProject, @NotNull Element paramElement)
/* 117:    */   {
/* 118:114 */     if (paramJpsProject == null) {
/* 119:114 */       throw new IllegalArgumentException(String.format("Argument %s for @NotNull parameter of %s.%s must not be null", new Object[] { "0", "org/jetbrains/jps/model/serialization/java/compiler/JpsJavaCompilerConfigurationSerializer", "saveExtension" }));
/* 120:    */     }
/* 121:114 */     if (paramElement == null) {
/* 122:114 */       throw new IllegalArgumentException(String.format("Argument %s for @NotNull parameter of %s.%s must not be null", new Object[] { "1", "org/jetbrains/jps/model/serialization/java/compiler/JpsJavaCompilerConfigurationSerializer", "saveExtension" }));
/* 123:    */     }
/* 124:    */   }
/* 125:    */ }



/* Location:           E:\idea\

 * Qualified Name:     org.jetbrains.jps.model.serialization.java.compiler.JpsJavaCompilerConfigurationSerializer

 * JD-Core Version:    0.7.0.1

 */